package com.darrenchan.leetcode;

import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;

/**
 * @Desc
 * @Author chenchi03
 * @CreateTime 2019-12-28 17:27
 */
public class Q9 {
    public boolean isPalindrome(int x) {
        if(x < 0){
            return false;
        }
        Stack<Integer> stack = new Stack<>();
        Queue<Integer> queue = new LinkedList<>();
        while(x > 0) {
            stack.add(x % 10);
            queue.add(x % 10);
            x /= 10;
        }

        while (!stack.isEmpty() && !queue.isEmpty()) {
            if(stack.pop() != queue.poll()){
                return false;
            }
        }
        return true;
    }
}
